﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AwesomeEnginePC.Timing
{
    public class TimingSystem
    {
        public TimeSpan PreviousTime { get; protected set; }
        public TimeSpan TargetTimeSpan { get; set; }

        public TimingSystem()
        {
        }

        public void SetTiming(TimeSpan targetTimeSpan, TimeSpan currentTime)
        {
            TargetTimeSpan = targetTimeSpan;
            PreviousTime = new TimeSpan(currentTime.Ticks);
        }

        public bool HasTargetTimeElapsed(TimeSpan currentTime)
        {
            if (currentTime - PreviousTime >= TargetTimeSpan)
            {
                //reset previous time
                PreviousTime = new TimeSpan(currentTime.Ticks);
                return true;
            }

            return false;
        }
    }
}
